package com.lovo.bbs.bo;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

import javax.naming.NamingException;

import com.lovo.bbs.dao.RankDao;
import com.lovo.bbs.po.RankPo;
import com.lovo.bbs.vo.RankVo;

/**
 * 等级Bo
 * 
 * @author tiancen2001
 * 
 */
public class RankBo {
	/**
	 * 取得等级Vo列表
	 */
	public  ArrayList<RankVo> getAllRank(){
		ArrayList<RankVo> vos = new ArrayList<RankVo>();
		ArrayList<RankPo> pos=null;
		try {
			pos = new RankDao().getAllRank();
		} catch (NamingException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		Iterator<RankPo> it= pos.iterator();
		while(it.hasNext()){
			RankPo po = it.next();
			RankVo vo = new RankVo();
			
			vo.setRankid(po.getRankid());
			vo.setRankname(po.getRankname());
			vo.setRankimg(po.getRankimg());
			vo.setRanktitle(po.getRanktitle());
			
			vos.add(vo);
		}
		return vos;
	}
	
	
	/**
	 * 取得等级Map
	 * 
	 * @return
	 */
	public  HashMap<Integer, RankVo> getRankMap() {
		HashMap<Integer, RankVo> rankMap = new HashMap<Integer, RankVo>();
		ArrayList<RankVo> vos = getAllRank();
		Iterator<RankVo> it = vos.iterator();
		while(it.hasNext()){
			RankVo vo = it.next();
			rankMap.put(Integer.valueOf(vo.getRankid()), vo);
		}
		return rankMap;
	}
}
